<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Doxygen: pcl::StaticRangeCoder类 参考</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Doxygen
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'搜索','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('classpcl_1_1_static_range_coder.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#pub-methods">Public 成员函数</a> &#124;
<a href="#pro-types">Protected 类型</a> &#124;
<a href="#pro-methods">Protected 成员函数</a> &#124;
<a href="#pri-attribs">Private 属性</a> &#124;
<a href="classpcl_1_1_static_range_coder-members.html">所有成员列表</a>  </div>
  <div class="headertitle">
<div class="title">pcl::StaticRangeCoder类 参考</div>  </div>
</div><!--header-->
<div class="contents">

<p><b><a class="el" href="classpcl_1_1_static_range_coder.html" title="StaticRangeCoder compression class">StaticRangeCoder</a></b> compression class  
 <a href="classpcl_1_1_static_range_coder.html#details">更多...</a></p>

<p><code>#include &lt;<a class="el" href="entropy__range__coder_8h_source.html">entropy_range_coder.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public 成员函数</h2></td></tr>
<tr class="memitem:a8db06a387174781c5bd26128807ef04f"><td class="memItemLeft" align="right" valign="top"><a id="a8db06a387174781c5bd26128807ef04f"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpcl_1_1_static_range_coder.html#a8db06a387174781c5bd26128807ef04f">StaticRangeCoder</a> ()</td></tr>
<tr class="memdesc:a8db06a387174781c5bd26128807ef04f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructor. <br /></td></tr>
<tr class="separator:a8db06a387174781c5bd26128807ef04f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afb5a5baeea0b4b20ffa8a3034df0da6c"><td class="memItemLeft" align="right" valign="top"><a id="afb5a5baeea0b4b20ffa8a3034df0da6c"></a>
virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpcl_1_1_static_range_coder.html#afb5a5baeea0b4b20ffa8a3034df0da6c">~StaticRangeCoder</a> ()</td></tr>
<tr class="memdesc:afb5a5baeea0b4b20ffa8a3034df0da6c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Empty deconstructor. <br /></td></tr>
<tr class="separator:afb5a5baeea0b4b20ffa8a3034df0da6c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abd6ba03206efe9ae323b31f3017bca6d"><td class="memItemLeft" align="right" valign="top">unsigned long&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpcl_1_1_static_range_coder.html#abd6ba03206efe9ae323b31f3017bca6d">encodeIntVectorToStream</a> (std::vector&lt; unsigned int &gt; &amp;inputIntVector_arg, std::ostream &amp;outputByterStream_arg)</td></tr>
<tr class="memdesc:abd6ba03206efe9ae323b31f3017bca6d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Encode integer vector to output stream  <a href="classpcl_1_1_static_range_coder.html#abd6ba03206efe9ae323b31f3017bca6d">更多...</a><br /></td></tr>
<tr class="separator:abd6ba03206efe9ae323b31f3017bca6d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a305b6e69719a46b880d452ee96f17697"><td class="memItemLeft" align="right" valign="top">unsigned long&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpcl_1_1_static_range_coder.html#a305b6e69719a46b880d452ee96f17697">decodeStreamToIntVector</a> (std::istream &amp;inputByteStream_arg, std::vector&lt; unsigned int &gt; &amp;outputIntVector_arg)</td></tr>
<tr class="memdesc:a305b6e69719a46b880d452ee96f17697"><td class="mdescLeft">&#160;</td><td class="mdescRight">Decode stream to output integer vector  <a href="classpcl_1_1_static_range_coder.html#a305b6e69719a46b880d452ee96f17697">更多...</a><br /></td></tr>
<tr class="separator:a305b6e69719a46b880d452ee96f17697"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8728a6d530d9ae47861e720f4d3a431a"><td class="memItemLeft" align="right" valign="top">unsigned long&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpcl_1_1_static_range_coder.html#a8728a6d530d9ae47861e720f4d3a431a">encodeCharVectorToStream</a> (const std::vector&lt; char &gt; &amp;inputByteVector_arg, std::ostream &amp;outputByteStream_arg)</td></tr>
<tr class="memdesc:a8728a6d530d9ae47861e720f4d3a431a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Encode char vector to output stream  <a href="classpcl_1_1_static_range_coder.html#a8728a6d530d9ae47861e720f4d3a431a">更多...</a><br /></td></tr>
<tr class="separator:a8728a6d530d9ae47861e720f4d3a431a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aaf7fb7f55fa59fdaf3cd394eb91f9bf2"><td class="memItemLeft" align="right" valign="top">unsigned long&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpcl_1_1_static_range_coder.html#aaf7fb7f55fa59fdaf3cd394eb91f9bf2">decodeStreamToCharVector</a> (std::istream &amp;inputByteStream_arg, std::vector&lt; char &gt; &amp;outputByteVector_arg)</td></tr>
<tr class="memdesc:aaf7fb7f55fa59fdaf3cd394eb91f9bf2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Decode char stream to output vector  <a href="classpcl_1_1_static_range_coder.html#aaf7fb7f55fa59fdaf3cd394eb91f9bf2">更多...</a><br /></td></tr>
<tr class="separator:aaf7fb7f55fa59fdaf3cd394eb91f9bf2"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-types"></a>
Protected 类型</h2></td></tr>
<tr class="memitem:a58e295a8f101329854db1fbba7f4ee9e"><td class="memItemLeft" align="right" valign="top"><a id="a58e295a8f101329854db1fbba7f4ee9e"></a>
typedef boost::uint32_t&#160;</td><td class="memItemRight" valign="bottom"><b>DWord</b></td></tr>
<tr class="separator:a58e295a8f101329854db1fbba7f4ee9e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected 成员函数</h2></td></tr>
<tr class="memitem:a72b5f38f745569b4ef06d1c6a4db9b74"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpcl_1_1_static_range_coder.html#a72b5f38f745569b4ef06d1c6a4db9b74">Log2</a> (double n_arg)</td></tr>
<tr class="memdesc:a72b5f38f745569b4ef06d1c6a4db9b74"><td class="mdescLeft">&#160;</td><td class="mdescRight">Helper function to calculate the binary logarithm  <a href="classpcl_1_1_static_range_coder.html#a72b5f38f745569b4ef06d1c6a4db9b74">更多...</a><br /></td></tr>
<tr class="separator:a72b5f38f745569b4ef06d1c6a4db9b74"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pri-attribs"></a>
Private 属性</h2></td></tr>
<tr class="memitem:a8e3d92557b5e9b58164519a75b104cb5"><td class="memItemLeft" align="right" valign="top"><a id="a8e3d92557b5e9b58164519a75b104cb5"></a>
std::vector&lt; uint64_t &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a></td></tr>
<tr class="memdesc:a8e3d92557b5e9b58164519a75b104cb5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Vector containing cumulative symbol frequency table. <br /></td></tr>
<tr class="separator:a8e3d92557b5e9b58164519a75b104cb5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a47a655dfb4939a02e7b16af1ec649ae1"><td class="memItemLeft" align="right" valign="top"><a id="a47a655dfb4939a02e7b16af1ec649ae1"></a>
std::vector&lt; char &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpcl_1_1_static_range_coder.html#a47a655dfb4939a02e7b16af1ec649ae1">outputCharVector_</a></td></tr>
<tr class="memdesc:a47a655dfb4939a02e7b16af1ec649ae1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Vector containing compressed data. <br /></td></tr>
<tr class="separator:a47a655dfb4939a02e7b16af1ec649ae1"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<div class="textblock"><p><b><a class="el" href="classpcl_1_1_static_range_coder.html" title="StaticRangeCoder compression class">StaticRangeCoder</a></b> compression class </p>
<dl class="section note"><dt>注解</dt><dd>This class provides static range coding functionality. </dd>
<dd>
Its symbol probability/frequency table is precomputed and encoded to the output stream </dd>
<dd>
</dd></dl>
<dl class="section author"><dt>作者</dt><dd>Julius Kammerl (<a href="#" onclick="location.href='mai'+'lto:'+'jul'+'iu'+'s@k'+'am'+'mer'+'l.'+'de'; return false;">juliu<span style="display: none;">.nosp@m.</span>s@ka<span style="display: none;">.nosp@m.</span>mmerl<span style="display: none;">.nosp@m.</span>.de</a>) </dd></dl>
</div><h2 class="groupheader">成员函数说明</h2>
<a id="aaf7fb7f55fa59fdaf3cd394eb91f9bf2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aaf7fb7f55fa59fdaf3cd394eb91f9bf2">&#9670;&nbsp;</a></span>decodeStreamToCharVector()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned long pcl::StaticRangeCoder::decodeStreamToCharVector </td>
          <td>(</td>
          <td class="paramtype">std::istream &amp;&#160;</td>
          <td class="paramname"><em>inputByteStream_arg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::vector&lt; char &gt; &amp;&#160;</td>
          <td class="paramname"><em>outputByteVector_arg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Decode char stream to output vector </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">inputByteStream_arg</td><td>input stream of compressed data </td></tr>
    <tr><td class="paramname">outputByteVector_arg</td><td>decompressed output vector </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>amount of bytes read from input stream </dd></dl>
<div class="fragment"><div class="line"><a name="l00603"></a><span class="lineno">  603</span>&#160;{</div>
<div class="line"><a name="l00604"></a><span class="lineno">  604</span>&#160;  uint8_t ch;</div>
<div class="line"><a name="l00605"></a><span class="lineno">  605</span>&#160;  DWord freq[257];</div>
<div class="line"><a name="l00606"></a><span class="lineno">  606</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;</div>
<div class="line"><a name="l00607"></a><span class="lineno">  607</span>&#160; </div>
<div class="line"><a name="l00608"></a><span class="lineno">  608</span>&#160;  <span class="comment">// define range limits</span></div>
<div class="line"><a name="l00609"></a><span class="lineno">  609</span>&#160;  <span class="keyword">const</span> DWord top = <span class="keyword">static_cast&lt;</span>DWord<span class="keyword">&gt;</span> (1) &lt;&lt; 24;</div>
<div class="line"><a name="l00610"></a><span class="lineno">  610</span>&#160;  <span class="keyword">const</span> DWord bottom = <span class="keyword">static_cast&lt;</span>DWord<span class="keyword">&gt;</span> (1) &lt;&lt; 16;</div>
<div class="line"><a name="l00611"></a><span class="lineno">  611</span>&#160; </div>
<div class="line"><a name="l00612"></a><span class="lineno">  612</span>&#160;  DWord low, range;</div>
<div class="line"><a name="l00613"></a><span class="lineno">  613</span>&#160;  DWord <a class="code" href="structcode.html">code</a>;</div>
<div class="line"><a name="l00614"></a><span class="lineno">  614</span>&#160; </div>
<div class="line"><a name="l00615"></a><span class="lineno">  615</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> outputBufPos;</div>
<div class="line"><a name="l00616"></a><span class="lineno">  616</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> output_size;</div>
<div class="line"><a name="l00617"></a><span class="lineno">  617</span>&#160; </div>
<div class="line"><a name="l00618"></a><span class="lineno">  618</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> streamByteCount;</div>
<div class="line"><a name="l00619"></a><span class="lineno">  619</span>&#160; </div>
<div class="line"><a name="l00620"></a><span class="lineno">  620</span>&#160;  streamByteCount = 0;</div>
<div class="line"><a name="l00621"></a><span class="lineno">  621</span>&#160; </div>
<div class="line"><a name="l00622"></a><span class="lineno">  622</span>&#160;  output_size = <span class="keyword">static_cast&lt;</span><span class="keywordtype">unsigned</span> <span class="keywordtype">int</span><span class="keyword">&gt;</span> (outputByteVector_arg.size ());</div>
<div class="line"><a name="l00623"></a><span class="lineno">  623</span>&#160; </div>
<div class="line"><a name="l00624"></a><span class="lineno">  624</span>&#160;  outputBufPos = 0;</div>
<div class="line"><a name="l00625"></a><span class="lineno">  625</span>&#160; </div>
<div class="line"><a name="l00626"></a><span class="lineno">  626</span>&#160;  <span class="comment">// read cumulative frequency table</span></div>
<div class="line"><a name="l00627"></a><span class="lineno">  627</span>&#160;  inputByteStream_arg.read (<span class="keyword">reinterpret_cast&lt;</span><span class="keywordtype">char</span>*<span class="keyword">&gt;</span> (&amp;freq[0]), <span class="keyword">sizeof</span>(freq));</div>
<div class="line"><a name="l00628"></a><span class="lineno">  628</span>&#160;  streamByteCount += <span class="keyword">sizeof</span>(freq);</div>
<div class="line"><a name="l00629"></a><span class="lineno">  629</span>&#160; </div>
<div class="line"><a name="l00630"></a><span class="lineno">  630</span>&#160;  <a class="code" href="structcode.html">code</a> = 0;</div>
<div class="line"><a name="l00631"></a><span class="lineno">  631</span>&#160;  low = 0;</div>
<div class="line"><a name="l00632"></a><span class="lineno">  632</span>&#160;  range = <span class="keyword">static_cast&lt;</span>DWord<span class="keyword">&gt;</span> (-1);</div>
<div class="line"><a name="l00633"></a><span class="lineno">  633</span>&#160; </div>
<div class="line"><a name="l00634"></a><span class="lineno">  634</span>&#160;  <span class="comment">// init code</span></div>
<div class="line"><a name="l00635"></a><span class="lineno">  635</span>&#160;  <span class="keywordflow">for</span> (i = 0; i &lt; 4; i++)</div>
<div class="line"><a name="l00636"></a><span class="lineno">  636</span>&#160;  {</div>
<div class="line"><a name="l00637"></a><span class="lineno">  637</span>&#160;    inputByteStream_arg.read (<span class="keyword">reinterpret_cast&lt;</span><span class="keywordtype">char</span>*<span class="keyword">&gt;</span> (&amp;ch), <span class="keyword">sizeof</span>(char));</div>
<div class="line"><a name="l00638"></a><span class="lineno">  638</span>&#160;    streamByteCount += <span class="keyword">sizeof</span>(char);</div>
<div class="line"><a name="l00639"></a><span class="lineno">  639</span>&#160;    <a class="code" href="structcode.html">code</a> = (<a class="code" href="structcode.html">code</a> &lt;&lt; 8) | ch;</div>
<div class="line"><a name="l00640"></a><span class="lineno">  640</span>&#160;  }</div>
<div class="line"><a name="l00641"></a><span class="lineno">  641</span>&#160; </div>
<div class="line"><a name="l00642"></a><span class="lineno">  642</span>&#160;  <span class="comment">// decoding</span></div>
<div class="line"><a name="l00643"></a><span class="lineno">  643</span>&#160;  <span class="keywordflow">for</span> (i = 0; i &lt; output_size; i++)</div>
<div class="line"><a name="l00644"></a><span class="lineno">  644</span>&#160;  {</div>
<div class="line"><a name="l00645"></a><span class="lineno">  645</span>&#160;    <span class="comment">// symbol lookup in cumulative frequency table</span></div>
<div class="line"><a name="l00646"></a><span class="lineno">  646</span>&#160;    uint8_t symbol = 0;</div>
<div class="line"><a name="l00647"></a><span class="lineno">  647</span>&#160;    uint8_t sSize = 256 / 2;</div>
<div class="line"><a name="l00648"></a><span class="lineno">  648</span>&#160; </div>
<div class="line"><a name="l00649"></a><span class="lineno">  649</span>&#160;    DWord count = (<a class="code" href="structcode.html">code</a> - low) / (range /= freq[256]);</div>
<div class="line"><a name="l00650"></a><span class="lineno">  650</span>&#160; </div>
<div class="line"><a name="l00651"></a><span class="lineno">  651</span>&#160;    <span class="keywordflow">while</span> (sSize &gt; 0)</div>
<div class="line"><a name="l00652"></a><span class="lineno">  652</span>&#160;    {</div>
<div class="line"><a name="l00653"></a><span class="lineno">  653</span>&#160;      <span class="keywordflow">if</span> (freq[symbol + sSize] &lt;= count)</div>
<div class="line"><a name="l00654"></a><span class="lineno">  654</span>&#160;      {</div>
<div class="line"><a name="l00655"></a><span class="lineno">  655</span>&#160;        symbol = <span class="keyword">static_cast&lt;</span>uint8_t<span class="keyword">&gt;</span> (symbol + sSize);</div>
<div class="line"><a name="l00656"></a><span class="lineno">  656</span>&#160;      }</div>
<div class="line"><a name="l00657"></a><span class="lineno">  657</span>&#160;      sSize /= 2;</div>
<div class="line"><a name="l00658"></a><span class="lineno">  658</span>&#160;    }</div>
<div class="line"><a name="l00659"></a><span class="lineno">  659</span>&#160; </div>
<div class="line"><a name="l00660"></a><span class="lineno">  660</span>&#160;    <span class="comment">// write symbol to output stream</span></div>
<div class="line"><a name="l00661"></a><span class="lineno">  661</span>&#160;    outputByteVector_arg[outputBufPos++] = symbol;</div>
<div class="line"><a name="l00662"></a><span class="lineno">  662</span>&#160; </div>
<div class="line"><a name="l00663"></a><span class="lineno">  663</span>&#160;    low += freq[symbol] * range;</div>
<div class="line"><a name="l00664"></a><span class="lineno">  664</span>&#160;    range *= freq[symbol + 1] - freq[symbol];</div>
<div class="line"><a name="l00665"></a><span class="lineno">  665</span>&#160; </div>
<div class="line"><a name="l00666"></a><span class="lineno">  666</span>&#160;    <span class="comment">// check range limits</span></div>
<div class="line"><a name="l00667"></a><span class="lineno">  667</span>&#160;    <span class="keywordflow">while</span> ((low ^ (low + range)) &lt; top || ((range &lt; bottom) &amp;&amp; ((range = -int (low) &amp; (bottom - 1)), 1)))</div>
<div class="line"><a name="l00668"></a><span class="lineno">  668</span>&#160;    {</div>
<div class="line"><a name="l00669"></a><span class="lineno">  669</span>&#160;      inputByteStream_arg.read (<span class="keyword">reinterpret_cast&lt;</span><span class="keywordtype">char</span>*<span class="keyword">&gt;</span> (&amp;ch), <span class="keyword">sizeof</span>(char));</div>
<div class="line"><a name="l00670"></a><span class="lineno">  670</span>&#160;      streamByteCount += <span class="keyword">sizeof</span>(char);</div>
<div class="line"><a name="l00671"></a><span class="lineno">  671</span>&#160;      <a class="code" href="structcode.html">code</a> = <a class="code" href="structcode.html">code</a> &lt;&lt; 8 | ch;</div>
<div class="line"><a name="l00672"></a><span class="lineno">  672</span>&#160;      range &lt;&lt;= 8;</div>
<div class="line"><a name="l00673"></a><span class="lineno">  673</span>&#160;      low &lt;&lt;= 8;</div>
<div class="line"><a name="l00674"></a><span class="lineno">  674</span>&#160;    }</div>
<div class="line"><a name="l00675"></a><span class="lineno">  675</span>&#160; </div>
<div class="line"><a name="l00676"></a><span class="lineno">  676</span>&#160;  }</div>
<div class="line"><a name="l00677"></a><span class="lineno">  677</span>&#160; </div>
<div class="line"><a name="l00678"></a><span class="lineno">  678</span>&#160;  <span class="keywordflow">return</span> (streamByteCount);</div>
<div class="line"><a name="l00679"></a><span class="lineno">  679</span>&#160;}</div>
<div class="ttc" id="astructcode_html"><div class="ttname"><a href="structcode.html">code</a></div><div class="ttdef"><b>Definition:</b> inftrees.h:24</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a305b6e69719a46b880d452ee96f17697"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a305b6e69719a46b880d452ee96f17697">&#9670;&nbsp;</a></span>decodeStreamToIntVector()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned long pcl::StaticRangeCoder::decodeStreamToIntVector </td>
          <td>(</td>
          <td class="paramtype">std::istream &amp;&#160;</td>
          <td class="paramname"><em>inputByteStream_arg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::vector&lt; unsigned int &gt; &amp;&#160;</td>
          <td class="paramname"><em>outputIntVector_arg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Decode stream to output integer vector </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">inputByteStream_arg</td><td>input stream of compressed data </td></tr>
    <tr><td class="paramname">outputIntVector_arg</td><td>decompressed output vector </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>amount of bytes read from input stream </dd></dl>
<div class="fragment"><div class="line"><a name="l00392"></a><span class="lineno">  392</span>&#160;{</div>
<div class="line"><a name="l00393"></a><span class="lineno">  393</span>&#160;  uint8_t ch;</div>
<div class="line"><a name="l00394"></a><span class="lineno">  394</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i, f;</div>
<div class="line"><a name="l00395"></a><span class="lineno">  395</span>&#160; </div>
<div class="line"><a name="l00396"></a><span class="lineno">  396</span>&#160;  <span class="comment">// define range limits</span></div>
<div class="line"><a name="l00397"></a><span class="lineno">  397</span>&#160;  <span class="keyword">const</span> uint64_t top = <span class="keyword">static_cast&lt;</span>uint64_t<span class="keyword">&gt;</span> (1) &lt;&lt; 56;</div>
<div class="line"><a name="l00398"></a><span class="lineno">  398</span>&#160;  <span class="keyword">const</span> uint64_t bottom = <span class="keyword">static_cast&lt;</span>uint64_t<span class="keyword">&gt;</span> (1) &lt;&lt; 48;</div>
<div class="line"><a name="l00399"></a><span class="lineno">  399</span>&#160; </div>
<div class="line"><a name="l00400"></a><span class="lineno">  400</span>&#160;  uint64_t low, range;</div>
<div class="line"><a name="l00401"></a><span class="lineno">  401</span>&#160;  uint64_t <a class="code" href="structcode.html">code</a>;</div>
<div class="line"><a name="l00402"></a><span class="lineno">  402</span>&#160; </div>
<div class="line"><a name="l00403"></a><span class="lineno">  403</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> outputBufPos;</div>
<div class="line"><a name="l00404"></a><span class="lineno">  404</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> output_size;</div>
<div class="line"><a name="l00405"></a><span class="lineno">  405</span>&#160; </div>
<div class="line"><a name="l00406"></a><span class="lineno">  406</span>&#160;  uint64_t frequencyTableSize;</div>
<div class="line"><a name="l00407"></a><span class="lineno">  407</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> frequencyTableByteSize;</div>
<div class="line"><a name="l00408"></a><span class="lineno">  408</span>&#160; </div>
<div class="line"><a name="l00409"></a><span class="lineno">  409</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> streamByteCount;</div>
<div class="line"><a name="l00410"></a><span class="lineno">  410</span>&#160; </div>
<div class="line"><a name="l00411"></a><span class="lineno">  411</span>&#160;  streamByteCount = 0;</div>
<div class="line"><a name="l00412"></a><span class="lineno">  412</span>&#160; </div>
<div class="line"><a name="l00413"></a><span class="lineno">  413</span>&#160;  outputBufPos = 0;</div>
<div class="line"><a name="l00414"></a><span class="lineno">  414</span>&#160;  output_size = <span class="keyword">static_cast&lt;</span><span class="keywordtype">unsigned</span> <span class="keywordtype">long</span><span class="keyword">&gt;</span> (outputIntVector_arg.size ());</div>
<div class="line"><a name="l00415"></a><span class="lineno">  415</span>&#160; </div>
<div class="line"><a name="l00416"></a><span class="lineno">  416</span>&#160;  <span class="comment">// read size of cumulative frequency table from stream</span></div>
<div class="line"><a name="l00417"></a><span class="lineno">  417</span>&#160;  inputByteStream_arg.read (<span class="keyword">reinterpret_cast&lt;</span><span class="keywordtype">char</span>*<span class="keyword">&gt;</span> (&amp;frequencyTableSize), <span class="keyword">sizeof</span>(frequencyTableSize));</div>
<div class="line"><a name="l00418"></a><span class="lineno">  418</span>&#160;  inputByteStream_arg.read (<span class="keyword">reinterpret_cast&lt;</span><span class="keywordtype">char</span>*<span class="keyword">&gt;</span> (&amp;frequencyTableByteSize), <span class="keyword">sizeof</span>(frequencyTableByteSize));</div>
<div class="line"><a name="l00419"></a><span class="lineno">  419</span>&#160; </div>
<div class="line"><a name="l00420"></a><span class="lineno">  420</span>&#160;  streamByteCount += <span class="keyword">sizeof</span>(frequencyTableSize) + <span class="keyword">sizeof</span>(frequencyTableByteSize);</div>
<div class="line"><a name="l00421"></a><span class="lineno">  421</span>&#160; </div>
<div class="line"><a name="l00422"></a><span class="lineno">  422</span>&#160;  <span class="comment">// check size of frequency table vector</span></div>
<div class="line"><a name="l00423"></a><span class="lineno">  423</span>&#160;  <span class="keywordflow">if</span> (<a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>.size () &lt; frequencyTableSize)</div>
<div class="line"><a name="l00424"></a><span class="lineno">  424</span>&#160;  {</div>
<div class="line"><a name="l00425"></a><span class="lineno">  425</span>&#160;    <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>.resize (<span class="keyword">static_cast&lt;</span>std::size_t<span class="keyword">&gt;</span> (frequencyTableSize));</div>
<div class="line"><a name="l00426"></a><span class="lineno">  426</span>&#160;  }</div>
<div class="line"><a name="l00427"></a><span class="lineno">  427</span>&#160; </div>
<div class="line"><a name="l00428"></a><span class="lineno">  428</span>&#160;  <span class="comment">// init with zero</span></div>
<div class="line"><a name="l00429"></a><span class="lineno">  429</span>&#160;  memset (&amp;<a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[0], 0, <span class="keyword">sizeof</span>(uint64_t) * <span class="keyword">static_cast&lt;</span>std::size_t<span class="keyword">&gt;</span> (frequencyTableSize));</div>
<div class="line"><a name="l00430"></a><span class="lineno">  430</span>&#160; </div>
<div class="line"><a name="l00431"></a><span class="lineno">  431</span>&#160;  <span class="comment">// read cumulative frequency table</span></div>
<div class="line"><a name="l00432"></a><span class="lineno">  432</span>&#160;  <span class="keywordflow">for</span> (f = 1; f &lt; frequencyTableSize; f++)</div>
<div class="line"><a name="l00433"></a><span class="lineno">  433</span>&#160;  {</div>
<div class="line"><a name="l00434"></a><span class="lineno">  434</span>&#160;    inputByteStream_arg.read (<span class="keyword">reinterpret_cast&lt;</span><span class="keywordtype">char</span> *<span class="keyword">&gt;</span> (&amp;<a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[f]), frequencyTableByteSize);</div>
<div class="line"><a name="l00435"></a><span class="lineno">  435</span>&#160;    streamByteCount += frequencyTableByteSize;</div>
<div class="line"><a name="l00436"></a><span class="lineno">  436</span>&#160;  }</div>
<div class="line"><a name="l00437"></a><span class="lineno">  437</span>&#160; </div>
<div class="line"><a name="l00438"></a><span class="lineno">  438</span>&#160;  <span class="comment">// initialize range &amp; code</span></div>
<div class="line"><a name="l00439"></a><span class="lineno">  439</span>&#160;  <a class="code" href="structcode.html">code</a> = 0;</div>
<div class="line"><a name="l00440"></a><span class="lineno">  440</span>&#160;  low = 0;</div>
<div class="line"><a name="l00441"></a><span class="lineno">  441</span>&#160;  range = <span class="keyword">static_cast&lt;</span>uint64_t<span class="keyword">&gt;</span> (-1);</div>
<div class="line"><a name="l00442"></a><span class="lineno">  442</span>&#160; </div>
<div class="line"><a name="l00443"></a><span class="lineno">  443</span>&#160;  <span class="comment">// init code vector</span></div>
<div class="line"><a name="l00444"></a><span class="lineno">  444</span>&#160;  <span class="keywordflow">for</span> (i = 0; i &lt; 8; i++)</div>
<div class="line"><a name="l00445"></a><span class="lineno">  445</span>&#160;  {</div>
<div class="line"><a name="l00446"></a><span class="lineno">  446</span>&#160;    inputByteStream_arg.read (<span class="keyword">reinterpret_cast&lt;</span><span class="keywordtype">char</span>*<span class="keyword">&gt;</span> (&amp;ch), <span class="keyword">sizeof</span>(char));</div>
<div class="line"><a name="l00447"></a><span class="lineno">  447</span>&#160;    streamByteCount += <span class="keyword">sizeof</span>(char);</div>
<div class="line"><a name="l00448"></a><span class="lineno">  448</span>&#160;    <a class="code" href="structcode.html">code</a> = (<a class="code" href="structcode.html">code</a> &lt;&lt; 8) | ch;</div>
<div class="line"><a name="l00449"></a><span class="lineno">  449</span>&#160;  }</div>
<div class="line"><a name="l00450"></a><span class="lineno">  450</span>&#160; </div>
<div class="line"><a name="l00451"></a><span class="lineno">  451</span>&#160;  <span class="comment">// decoding</span></div>
<div class="line"><a name="l00452"></a><span class="lineno">  452</span>&#160;  <span class="keywordflow">for</span> (i = 0; i &lt; output_size; i++)</div>
<div class="line"><a name="l00453"></a><span class="lineno">  453</span>&#160;  {</div>
<div class="line"><a name="l00454"></a><span class="lineno">  454</span>&#160;    uint64_t count = (<a class="code" href="structcode.html">code</a> - low) / (range /= <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[<span class="keyword">static_cast&lt;</span>std::size_t<span class="keyword">&gt;</span> (frequencyTableSize - 1)]);</div>
<div class="line"><a name="l00455"></a><span class="lineno">  455</span>&#160; </div>
<div class="line"><a name="l00456"></a><span class="lineno">  456</span>&#160;    <span class="comment">// symbol lookup in cumulative frequency table</span></div>
<div class="line"><a name="l00457"></a><span class="lineno">  457</span>&#160;    uint64_t symbol = 0;</div>
<div class="line"><a name="l00458"></a><span class="lineno">  458</span>&#160;    uint64_t sSize = (frequencyTableSize - 1) / 2;</div>
<div class="line"><a name="l00459"></a><span class="lineno">  459</span>&#160;    <span class="keywordflow">while</span> (sSize &gt; 0)</div>
<div class="line"><a name="l00460"></a><span class="lineno">  460</span>&#160;    {</div>
<div class="line"><a name="l00461"></a><span class="lineno">  461</span>&#160;      <span class="keywordflow">if</span> (<a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[<span class="keyword">static_cast&lt;</span>std::size_t<span class="keyword">&gt;</span> (symbol + sSize)] &lt;= count)</div>
<div class="line"><a name="l00462"></a><span class="lineno">  462</span>&#160;      {</div>
<div class="line"><a name="l00463"></a><span class="lineno">  463</span>&#160;        symbol += sSize;</div>
<div class="line"><a name="l00464"></a><span class="lineno">  464</span>&#160;      }</div>
<div class="line"><a name="l00465"></a><span class="lineno">  465</span>&#160;      sSize /= 2;</div>
<div class="line"><a name="l00466"></a><span class="lineno">  466</span>&#160;    }</div>
<div class="line"><a name="l00467"></a><span class="lineno">  467</span>&#160; </div>
<div class="line"><a name="l00468"></a><span class="lineno">  468</span>&#160;    <span class="comment">// write symbol to output stream</span></div>
<div class="line"><a name="l00469"></a><span class="lineno">  469</span>&#160;    outputIntVector_arg[outputBufPos++] = <span class="keyword">static_cast&lt;</span><span class="keywordtype">unsigned</span> <span class="keywordtype">int</span><span class="keyword">&gt;</span> (symbol);</div>
<div class="line"><a name="l00470"></a><span class="lineno">  470</span>&#160; </div>
<div class="line"><a name="l00471"></a><span class="lineno">  471</span>&#160;    <span class="comment">// map to range</span></div>
<div class="line"><a name="l00472"></a><span class="lineno">  472</span>&#160;    low += <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[<span class="keyword">static_cast&lt;</span>std::size_t<span class="keyword">&gt;</span> (symbol)] * range;</div>
<div class="line"><a name="l00473"></a><span class="lineno">  473</span>&#160;    range *= <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[<span class="keyword">static_cast&lt;</span>std::size_t<span class="keyword">&gt;</span> (symbol + 1)] - <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[<span class="keyword">static_cast&lt;</span>std::size_t<span class="keyword">&gt;</span> (symbol)];</div>
<div class="line"><a name="l00474"></a><span class="lineno">  474</span>&#160; </div>
<div class="line"><a name="l00475"></a><span class="lineno">  475</span>&#160;    <span class="comment">// check range limits</span></div>
<div class="line"><a name="l00476"></a><span class="lineno">  476</span>&#160;    <span class="keywordflow">while</span> ((low ^ (low + range)) &lt; top || ((range &lt; bottom) &amp;&amp; ((range = -low &amp; (bottom - 1)), 1)))</div>
<div class="line"><a name="l00477"></a><span class="lineno">  477</span>&#160;    {</div>
<div class="line"><a name="l00478"></a><span class="lineno">  478</span>&#160;      inputByteStream_arg.read (<span class="keyword">reinterpret_cast&lt;</span><span class="keywordtype">char</span>*<span class="keyword">&gt;</span> (&amp;ch), <span class="keyword">sizeof</span>(char));</div>
<div class="line"><a name="l00479"></a><span class="lineno">  479</span>&#160;      streamByteCount += <span class="keyword">sizeof</span>(char);</div>
<div class="line"><a name="l00480"></a><span class="lineno">  480</span>&#160;      <a class="code" href="structcode.html">code</a> = <a class="code" href="structcode.html">code</a> &lt;&lt; 8 | ch;</div>
<div class="line"><a name="l00481"></a><span class="lineno">  481</span>&#160;      range &lt;&lt;= 8;</div>
<div class="line"><a name="l00482"></a><span class="lineno">  482</span>&#160;      low &lt;&lt;= 8;</div>
<div class="line"><a name="l00483"></a><span class="lineno">  483</span>&#160;    }</div>
<div class="line"><a name="l00484"></a><span class="lineno">  484</span>&#160; </div>
<div class="line"><a name="l00485"></a><span class="lineno">  485</span>&#160;  }</div>
<div class="line"><a name="l00486"></a><span class="lineno">  486</span>&#160; </div>
<div class="line"><a name="l00487"></a><span class="lineno">  487</span>&#160;  <span class="keywordflow">return</span> streamByteCount;</div>
<div class="line"><a name="l00488"></a><span class="lineno">  488</span>&#160;}</div>
<div class="ttc" id="aclasspcl_1_1_static_range_coder_html_a8e3d92557b5e9b58164519a75b104cb5"><div class="ttname"><a href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">pcl::StaticRangeCoder::cFreqTable_</a></div><div class="ttdeci">std::vector&lt; uint64_t &gt; cFreqTable_</div><div class="ttdoc">Vector containing cumulative symbol frequency table.</div><div class="ttdef"><b>Definition:</b> entropy_range_coder.h:180</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a8728a6d530d9ae47861e720f4d3a431a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8728a6d530d9ae47861e720f4d3a431a">&#9670;&nbsp;</a></span>encodeCharVectorToStream()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned long pcl::StaticRangeCoder::encodeCharVectorToStream </td>
          <td>(</td>
          <td class="paramtype">const std::vector&lt; char &gt; &amp;&#160;</td>
          <td class="paramname"><em>inputByteVector_arg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::ostream &amp;&#160;</td>
          <td class="paramname"><em>outputByteStream_arg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Encode char vector to output stream </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">inputByteVector_arg</td><td>input vector </td></tr>
    <tr><td class="paramname">outputByteStream_arg</td><td>output stream containing compressed data </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>amount of bytes written to output stream </dd></dl>
<div class="fragment"><div class="line"><a name="l00494"></a><span class="lineno">  494</span>&#160;{</div>
<div class="line"><a name="l00495"></a><span class="lineno">  495</span>&#160;  DWord freq[257];</div>
<div class="line"><a name="l00496"></a><span class="lineno">  496</span>&#160;  uint8_t ch;</div>
<div class="line"><a name="l00497"></a><span class="lineno">  497</span>&#160;  <span class="keywordtype">int</span> i, f;</div>
<div class="line"><a name="l00498"></a><span class="lineno">  498</span>&#160;  <span class="keywordtype">char</span> out;</div>
<div class="line"><a name="l00499"></a><span class="lineno">  499</span>&#160; </div>
<div class="line"><a name="l00500"></a><span class="lineno">  500</span>&#160;  <span class="comment">// define numerical limits</span></div>
<div class="line"><a name="l00501"></a><span class="lineno">  501</span>&#160;  <span class="keyword">const</span> DWord top = <span class="keyword">static_cast&lt;</span>DWord<span class="keyword">&gt;</span> (1) &lt;&lt; 24;</div>
<div class="line"><a name="l00502"></a><span class="lineno">  502</span>&#160;  <span class="keyword">const</span> DWord bottom = <span class="keyword">static_cast&lt;</span>DWord<span class="keyword">&gt;</span> (1) &lt;&lt; 16;</div>
<div class="line"><a name="l00503"></a><span class="lineno">  503</span>&#160;  <span class="keyword">const</span> DWord maxRange = <span class="keyword">static_cast&lt;</span>DWord<span class="keyword">&gt;</span> (1) &lt;&lt; 16;</div>
<div class="line"><a name="l00504"></a><span class="lineno">  504</span>&#160; </div>
<div class="line"><a name="l00505"></a><span class="lineno">  505</span>&#160;  DWord low, range;</div>
<div class="line"><a name="l00506"></a><span class="lineno">  506</span>&#160; </div>
<div class="line"><a name="l00507"></a><span class="lineno">  507</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> input_size;</div>
<div class="line"><a name="l00508"></a><span class="lineno">  508</span>&#160;  input_size = <span class="keyword">static_cast&lt;</span><span class="keywordtype">unsigned</span> <span class="keywordtype">int</span><span class="keyword">&gt;</span> (inputByteVector_arg.size ());</div>
<div class="line"><a name="l00509"></a><span class="lineno">  509</span>&#160; </div>
<div class="line"><a name="l00510"></a><span class="lineno">  510</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> readPos;</div>
<div class="line"><a name="l00511"></a><span class="lineno">  511</span>&#160; </div>
<div class="line"><a name="l00512"></a><span class="lineno">  512</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> streamByteCount;</div>
<div class="line"><a name="l00513"></a><span class="lineno">  513</span>&#160; </div>
<div class="line"><a name="l00514"></a><span class="lineno">  514</span>&#160;  streamByteCount = 0;</div>
<div class="line"><a name="l00515"></a><span class="lineno">  515</span>&#160; </div>
<div class="line"><a name="l00516"></a><span class="lineno">  516</span>&#160;  <span class="comment">// init output vector</span></div>
<div class="line"><a name="l00517"></a><span class="lineno">  517</span>&#160;  <a class="code" href="classpcl_1_1_static_range_coder.html#a47a655dfb4939a02e7b16af1ec649ae1">outputCharVector_</a>.clear ();</div>
<div class="line"><a name="l00518"></a><span class="lineno">  518</span>&#160;  <a class="code" href="classpcl_1_1_static_range_coder.html#a47a655dfb4939a02e7b16af1ec649ae1">outputCharVector_</a>.reserve (<span class="keyword">sizeof</span>(<span class="keywordtype">char</span>) * input_size);</div>
<div class="line"><a name="l00519"></a><span class="lineno">  519</span>&#160; </div>
<div class="line"><a name="l00520"></a><span class="lineno">  520</span>&#160;  uint64_t FreqHist[257];</div>
<div class="line"><a name="l00521"></a><span class="lineno">  521</span>&#160; </div>
<div class="line"><a name="l00522"></a><span class="lineno">  522</span>&#160;  <span class="comment">// calculate frequency table</span></div>
<div class="line"><a name="l00523"></a><span class="lineno">  523</span>&#160;  memset (FreqHist, 0, <span class="keyword">sizeof</span>(FreqHist));</div>
<div class="line"><a name="l00524"></a><span class="lineno">  524</span>&#160;  readPos = 0;</div>
<div class="line"><a name="l00525"></a><span class="lineno">  525</span>&#160;  <span class="keywordflow">while</span> (readPos &lt; input_size)</div>
<div class="line"><a name="l00526"></a><span class="lineno">  526</span>&#160;  {</div>
<div class="line"><a name="l00527"></a><span class="lineno">  527</span>&#160;    uint8_t symbol = <span class="keyword">static_cast&lt;</span>uint8_t<span class="keyword">&gt;</span> (inputByteVector_arg[readPos++]);</div>
<div class="line"><a name="l00528"></a><span class="lineno">  528</span>&#160;    FreqHist[symbol + 1]++;</div>
<div class="line"><a name="l00529"></a><span class="lineno">  529</span>&#160;  }</div>
<div class="line"><a name="l00530"></a><span class="lineno">  530</span>&#160; </div>
<div class="line"><a name="l00531"></a><span class="lineno">  531</span>&#160;  <span class="comment">// convert to cumulative frequency table</span></div>
<div class="line"><a name="l00532"></a><span class="lineno">  532</span>&#160;  freq[0] = 0;</div>
<div class="line"><a name="l00533"></a><span class="lineno">  533</span>&#160;  <span class="keywordflow">for</span> (f = 1; f &lt;= 256; f++)</div>
<div class="line"><a name="l00534"></a><span class="lineno">  534</span>&#160;  {</div>
<div class="line"><a name="l00535"></a><span class="lineno">  535</span>&#160;    freq[f] = freq[f - 1] + <span class="keyword">static_cast&lt;</span>DWord<span class="keyword">&gt;</span> (FreqHist[f]);</div>
<div class="line"><a name="l00536"></a><span class="lineno">  536</span>&#160;    <span class="keywordflow">if</span> (freq[f] &lt;= freq[f - 1])</div>
<div class="line"><a name="l00537"></a><span class="lineno">  537</span>&#160;      freq[f] = freq[f - 1] + 1;</div>
<div class="line"><a name="l00538"></a><span class="lineno">  538</span>&#160;  }</div>
<div class="line"><a name="l00539"></a><span class="lineno">  539</span>&#160; </div>
<div class="line"><a name="l00540"></a><span class="lineno">  540</span>&#160;  <span class="comment">// rescale if numerical limits are reached</span></div>
<div class="line"><a name="l00541"></a><span class="lineno">  541</span>&#160;  <span class="keywordflow">while</span> (freq[256] &gt;= maxRange)</div>
<div class="line"><a name="l00542"></a><span class="lineno">  542</span>&#160;  {</div>
<div class="line"><a name="l00543"></a><span class="lineno">  543</span>&#160;    <span class="keywordflow">for</span> (f = 1; f &lt;= 256; f++)</div>
<div class="line"><a name="l00544"></a><span class="lineno">  544</span>&#160;    {</div>
<div class="line"><a name="l00545"></a><span class="lineno">  545</span>&#160;      freq[f] /= 2;</div>
<div class="line"><a name="l00546"></a><span class="lineno">  546</span>&#160;      ;</div>
<div class="line"><a name="l00547"></a><span class="lineno">  547</span>&#160;      <span class="keywordflow">if</span> (freq[f] &lt;= freq[f - 1])</div>
<div class="line"><a name="l00548"></a><span class="lineno">  548</span>&#160;        freq[f] = freq[f - 1] + 1;</div>
<div class="line"><a name="l00549"></a><span class="lineno">  549</span>&#160;    }</div>
<div class="line"><a name="l00550"></a><span class="lineno">  550</span>&#160;  }</div>
<div class="line"><a name="l00551"></a><span class="lineno">  551</span>&#160; </div>
<div class="line"><a name="l00552"></a><span class="lineno">  552</span>&#160;  <span class="comment">// write cumulative  frequency table to output stream</span></div>
<div class="line"><a name="l00553"></a><span class="lineno">  553</span>&#160;  outputByteStream_arg.write (<span class="keyword">reinterpret_cast&lt;</span><span class="keyword">const </span><span class="keywordtype">char</span>*<span class="keyword">&gt;</span> (&amp;freq[0]), <span class="keyword">sizeof</span>(freq));</div>
<div class="line"><a name="l00554"></a><span class="lineno">  554</span>&#160;  streamByteCount += <span class="keyword">sizeof</span>(freq);</div>
<div class="line"><a name="l00555"></a><span class="lineno">  555</span>&#160; </div>
<div class="line"><a name="l00556"></a><span class="lineno">  556</span>&#160;  readPos = 0;</div>
<div class="line"><a name="l00557"></a><span class="lineno">  557</span>&#160; </div>
<div class="line"><a name="l00558"></a><span class="lineno">  558</span>&#160;  low = 0;</div>
<div class="line"><a name="l00559"></a><span class="lineno">  559</span>&#160;  range = <span class="keyword">static_cast&lt;</span>DWord<span class="keyword">&gt;</span> (-1);</div>
<div class="line"><a name="l00560"></a><span class="lineno">  560</span>&#160; </div>
<div class="line"><a name="l00561"></a><span class="lineno">  561</span>&#160;  <span class="comment">// start encoding</span></div>
<div class="line"><a name="l00562"></a><span class="lineno">  562</span>&#160;  <span class="keywordflow">while</span> (readPos &lt; input_size)</div>
<div class="line"><a name="l00563"></a><span class="lineno">  563</span>&#160;  {</div>
<div class="line"><a name="l00564"></a><span class="lineno">  564</span>&#160; </div>
<div class="line"><a name="l00565"></a><span class="lineno">  565</span>&#160;    <span class="comment">// read symol</span></div>
<div class="line"><a name="l00566"></a><span class="lineno">  566</span>&#160;    ch = inputByteVector_arg[readPos++];</div>
<div class="line"><a name="l00567"></a><span class="lineno">  567</span>&#160; </div>
<div class="line"><a name="l00568"></a><span class="lineno">  568</span>&#160;    <span class="comment">// map to range</span></div>
<div class="line"><a name="l00569"></a><span class="lineno">  569</span>&#160;    low += freq[ch] * (range /= freq[256]);</div>
<div class="line"><a name="l00570"></a><span class="lineno">  570</span>&#160;    range *= freq[ch + 1] - freq[ch];</div>
<div class="line"><a name="l00571"></a><span class="lineno">  571</span>&#160; </div>
<div class="line"><a name="l00572"></a><span class="lineno">  572</span>&#160;    <span class="comment">// check range limits</span></div>
<div class="line"><a name="l00573"></a><span class="lineno">  573</span>&#160;    <span class="keywordflow">while</span> ((low ^ (low + range)) &lt; top || ((range &lt; bottom) &amp;&amp; ((range = -int (low) &amp; (bottom - 1)), 1)))</div>
<div class="line"><a name="l00574"></a><span class="lineno">  574</span>&#160;    {</div>
<div class="line"><a name="l00575"></a><span class="lineno">  575</span>&#160;      out = <span class="keyword">static_cast&lt;</span><span class="keywordtype">char</span><span class="keyword">&gt;</span> (low &gt;&gt; 24);</div>
<div class="line"><a name="l00576"></a><span class="lineno">  576</span>&#160;      range &lt;&lt;= 8;</div>
<div class="line"><a name="l00577"></a><span class="lineno">  577</span>&#160;      low &lt;&lt;= 8;</div>
<div class="line"><a name="l00578"></a><span class="lineno">  578</span>&#160;      <a class="code" href="classpcl_1_1_static_range_coder.html#a47a655dfb4939a02e7b16af1ec649ae1">outputCharVector_</a>.push_back (out);</div>
<div class="line"><a name="l00579"></a><span class="lineno">  579</span>&#160;    }</div>
<div class="line"><a name="l00580"></a><span class="lineno">  580</span>&#160; </div>
<div class="line"><a name="l00581"></a><span class="lineno">  581</span>&#160;  }</div>
<div class="line"><a name="l00582"></a><span class="lineno">  582</span>&#160; </div>
<div class="line"><a name="l00583"></a><span class="lineno">  583</span>&#160;  <span class="comment">// flush remaining data</span></div>
<div class="line"><a name="l00584"></a><span class="lineno">  584</span>&#160;  <span class="keywordflow">for</span> (i = 0; i &lt; 4; i++)</div>
<div class="line"><a name="l00585"></a><span class="lineno">  585</span>&#160;  {</div>
<div class="line"><a name="l00586"></a><span class="lineno">  586</span>&#160;    out = <span class="keyword">static_cast&lt;</span><span class="keywordtype">char</span><span class="keyword">&gt;</span> (low &gt;&gt; 24);</div>
<div class="line"><a name="l00587"></a><span class="lineno">  587</span>&#160;    <a class="code" href="classpcl_1_1_static_range_coder.html#a47a655dfb4939a02e7b16af1ec649ae1">outputCharVector_</a>.push_back (out);</div>
<div class="line"><a name="l00588"></a><span class="lineno">  588</span>&#160;    low &lt;&lt;= 8;</div>
<div class="line"><a name="l00589"></a><span class="lineno">  589</span>&#160;  }</div>
<div class="line"><a name="l00590"></a><span class="lineno">  590</span>&#160; </div>
<div class="line"><a name="l00591"></a><span class="lineno">  591</span>&#160;  <span class="comment">// write encoded data to stream</span></div>
<div class="line"><a name="l00592"></a><span class="lineno">  592</span>&#160;  outputByteStream_arg.write (&amp;<a class="code" href="classpcl_1_1_static_range_coder.html#a47a655dfb4939a02e7b16af1ec649ae1">outputCharVector_</a>[0], <a class="code" href="classpcl_1_1_static_range_coder.html#a47a655dfb4939a02e7b16af1ec649ae1">outputCharVector_</a>.size ());</div>
<div class="line"><a name="l00593"></a><span class="lineno">  593</span>&#160; </div>
<div class="line"><a name="l00594"></a><span class="lineno">  594</span>&#160;  streamByteCount += <span class="keyword">static_cast&lt;</span><span class="keywordtype">unsigned</span> <span class="keywordtype">long</span><span class="keyword">&gt;</span> (<a class="code" href="classpcl_1_1_static_range_coder.html#a47a655dfb4939a02e7b16af1ec649ae1">outputCharVector_</a>.size ());</div>
<div class="line"><a name="l00595"></a><span class="lineno">  595</span>&#160; </div>
<div class="line"><a name="l00596"></a><span class="lineno">  596</span>&#160;  <span class="keywordflow">return</span> (streamByteCount);</div>
<div class="line"><a name="l00597"></a><span class="lineno">  597</span>&#160;}</div>
<div class="ttc" id="aclasspcl_1_1_static_range_coder_html_a47a655dfb4939a02e7b16af1ec649ae1"><div class="ttname"><a href="classpcl_1_1_static_range_coder.html#a47a655dfb4939a02e7b16af1ec649ae1">pcl::StaticRangeCoder::outputCharVector_</a></div><div class="ttdeci">std::vector&lt; char &gt; outputCharVector_</div><div class="ttdoc">Vector containing compressed data.</div><div class="ttdef"><b>Definition:</b> entropy_range_coder.h:183</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="abd6ba03206efe9ae323b31f3017bca6d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abd6ba03206efe9ae323b31f3017bca6d">&#9670;&nbsp;</a></span>encodeIntVectorToStream()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned long pcl::StaticRangeCoder::encodeIntVectorToStream </td>
          <td>(</td>
          <td class="paramtype">std::vector&lt; unsigned int &gt; &amp;&#160;</td>
          <td class="paramname"><em>inputIntVector_arg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::ostream &amp;&#160;</td>
          <td class="paramname"><em>outputByterStream_arg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Encode integer vector to output stream </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">inputIntVector_arg</td><td>input vector </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">outputByterStream_arg</td><td>output stream containing compressed data </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>amount of bytes written to output stream </dd></dl>
<div class="fragment"><div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;{</div>
<div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160; </div>
<div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> inputsymbol;</div>
<div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i, f;</div>
<div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;  <span class="keywordtype">char</span> out;</div>
<div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160; </div>
<div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;  uint64_t frequencyTableSize;</div>
<div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;  uint8_t frequencyTableByteSize;</div>
<div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160; </div>
<div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;  <span class="comment">// define numerical limits</span></div>
<div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;  <span class="keyword">const</span> uint64_t top = <span class="keyword">static_cast&lt;</span>uint64_t<span class="keyword">&gt;</span> (1) &lt;&lt; 56;</div>
<div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;  <span class="keyword">const</span> uint64_t bottom = <span class="keyword">static_cast&lt;</span>uint64_t<span class="keyword">&gt;</span> (1) &lt;&lt; 48;</div>
<div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;  <span class="keyword">const</span> uint64_t maxRange = <span class="keyword">static_cast&lt;</span>uint64_t<span class="keyword">&gt;</span> (1) &lt;&lt; 48;</div>
<div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160; </div>
<div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> input_size = <span class="keyword">static_cast&lt;</span><span class="keywordtype">unsigned</span> <span class="keywordtype">long</span><span class="keyword">&gt;</span> (inputIntVector_arg.size ());</div>
<div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;  uint64_t low, range;</div>
<div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160; </div>
<div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> inputSymbol;</div>
<div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160; </div>
<div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> readPos;</div>
<div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160; </div>
<div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;  <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> streamByteCount;</div>
<div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160; </div>
<div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;  streamByteCount = 0;</div>
<div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160; </div>
<div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;  <span class="comment">// init output vector</span></div>
<div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;  <a class="code" href="classpcl_1_1_static_range_coder.html#a47a655dfb4939a02e7b16af1ec649ae1">outputCharVector_</a>.clear ();</div>
<div class="line"><a name="l00271"></a><span class="lineno">  271</span>&#160;  <a class="code" href="classpcl_1_1_static_range_coder.html#a47a655dfb4939a02e7b16af1ec649ae1">outputCharVector_</a>.reserve ((<span class="keyword">sizeof</span>(<span class="keywordtype">char</span>) * input_size * 2));</div>
<div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160; </div>
<div class="line"><a name="l00273"></a><span class="lineno">  273</span>&#160;  frequencyTableSize = 1;</div>
<div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160; </div>
<div class="line"><a name="l00275"></a><span class="lineno">  275</span>&#160;  readPos = 0;</div>
<div class="line"><a name="l00276"></a><span class="lineno">  276</span>&#160; </div>
<div class="line"><a name="l00277"></a><span class="lineno">  277</span>&#160;  <span class="comment">// calculate frequency table</span></div>
<div class="line"><a name="l00278"></a><span class="lineno">  278</span>&#160;  <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[0] = <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[1] = 0;</div>
<div class="line"><a name="l00279"></a><span class="lineno">  279</span>&#160;  <span class="keywordflow">while</span> (readPos &lt; input_size)</div>
<div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;  {</div>
<div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;    inputSymbol = inputIntVector_arg[readPos++];</div>
<div class="line"><a name="l00282"></a><span class="lineno">  282</span>&#160; </div>
<div class="line"><a name="l00283"></a><span class="lineno">  283</span>&#160;    <span class="keywordflow">if</span> (inputSymbol + 1 &gt;= frequencyTableSize)</div>
<div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;    {</div>
<div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;      <span class="comment">// frequency table is to small -&gt; adaptively extend it</span></div>
<div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;      uint64_t oldfrequencyTableSize;</div>
<div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;      oldfrequencyTableSize = frequencyTableSize;</div>
<div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160; </div>
<div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;      <span class="keywordflow">do</span></div>
<div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160;      {</div>
<div class="line"><a name="l00291"></a><span class="lineno">  291</span>&#160;        <span class="comment">// increase frequency table size by factor 2</span></div>
<div class="line"><a name="l00292"></a><span class="lineno">  292</span>&#160;        frequencyTableSize &lt;&lt;= 1;</div>
<div class="line"><a name="l00293"></a><span class="lineno">  293</span>&#160;      } <span class="keywordflow">while</span> (inputSymbol + 1 &gt; frequencyTableSize);</div>
<div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160; </div>
<div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;      <span class="keywordflow">if</span> (<a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>.size () &lt; frequencyTableSize + 1)</div>
<div class="line"><a name="l00296"></a><span class="lineno">  296</span>&#160;      {</div>
<div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;        <span class="comment">// resize frequency vector</span></div>
<div class="line"><a name="l00298"></a><span class="lineno">  298</span>&#160;        <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>.resize (<span class="keyword">static_cast&lt;</span>std::size_t<span class="keyword">&gt;</span> (frequencyTableSize + 1));</div>
<div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;      }</div>
<div class="line"><a name="l00300"></a><span class="lineno">  300</span>&#160; </div>
<div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;      <span class="comment">// init new frequency range with zero</span></div>
<div class="line"><a name="l00302"></a><span class="lineno">  302</span>&#160;      memset (&amp;<a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[<span class="keyword">static_cast&lt;</span>std::size_t<span class="keyword">&gt;</span> (oldfrequencyTableSize + 1)], 0,</div>
<div class="line"><a name="l00303"></a><span class="lineno">  303</span>&#160;              <span class="keyword">sizeof</span>(uint64_t) * <span class="keyword">static_cast&lt;</span>std::size_t<span class="keyword">&gt;</span> (frequencyTableSize - oldfrequencyTableSize));</div>
<div class="line"><a name="l00304"></a><span class="lineno">  304</span>&#160;    }</div>
<div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160;    <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[inputSymbol + 1]++;</div>
<div class="line"><a name="l00306"></a><span class="lineno">  306</span>&#160;  }</div>
<div class="line"><a name="l00307"></a><span class="lineno">  307</span>&#160;  frequencyTableSize++;</div>
<div class="line"><a name="l00308"></a><span class="lineno">  308</span>&#160; </div>
<div class="line"><a name="l00309"></a><span class="lineno">  309</span>&#160;  <span class="comment">// convert to cumulative frequency table</span></div>
<div class="line"><a name="l00310"></a><span class="lineno">  310</span>&#160;  <span class="keywordflow">for</span> (f = 1; f &lt; frequencyTableSize; f++)</div>
<div class="line"><a name="l00311"></a><span class="lineno">  311</span>&#160;  {</div>
<div class="line"><a name="l00312"></a><span class="lineno">  312</span>&#160;    <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[f] = <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[f - 1] + <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[f];</div>
<div class="line"><a name="l00313"></a><span class="lineno">  313</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[f] &lt;= <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[f - 1])</div>
<div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;      <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[f] = <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[f - 1] + 1;</div>
<div class="line"><a name="l00315"></a><span class="lineno">  315</span>&#160;  }</div>
<div class="line"><a name="l00316"></a><span class="lineno">  316</span>&#160; </div>
<div class="line"><a name="l00317"></a><span class="lineno">  317</span>&#160;  <span class="comment">// rescale if numerical limits are reached</span></div>
<div class="line"><a name="l00318"></a><span class="lineno">  318</span>&#160;  <span class="keywordflow">while</span> (<a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[<span class="keyword">static_cast&lt;</span>std::size_t<span class="keyword">&gt;</span> (frequencyTableSize - 1)] &gt;= maxRange)</div>
<div class="line"><a name="l00319"></a><span class="lineno">  319</span>&#160;  {</div>
<div class="line"><a name="l00320"></a><span class="lineno">  320</span>&#160;    <span class="keywordflow">for</span> (f = 1; f &lt; <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>.size (); f++)</div>
<div class="line"><a name="l00321"></a><span class="lineno">  321</span>&#160;    {</div>
<div class="line"><a name="l00322"></a><span class="lineno">  322</span>&#160;      <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[f] /= 2;</div>
<div class="line"><a name="l00323"></a><span class="lineno">  323</span>&#160;      ;</div>
<div class="line"><a name="l00324"></a><span class="lineno">  324</span>&#160;      <span class="keywordflow">if</span> (<a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[f] &lt;= <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[f - 1])</div>
<div class="line"><a name="l00325"></a><span class="lineno">  325</span>&#160;        <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[f] = <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[f - 1] + 1;</div>
<div class="line"><a name="l00326"></a><span class="lineno">  326</span>&#160;    }</div>
<div class="line"><a name="l00327"></a><span class="lineno">  327</span>&#160;  }</div>
<div class="line"><a name="l00328"></a><span class="lineno">  328</span>&#160; </div>
<div class="line"><a name="l00329"></a><span class="lineno">  329</span>&#160;  <span class="comment">// calculate amount of bytes per frequency table entry</span></div>
<div class="line"><a name="l00330"></a><span class="lineno">  330</span>&#160;  frequencyTableByteSize = <span class="keyword">static_cast&lt;</span>uint8_t<span class="keyword">&gt;</span> (ceil (</div>
<div class="line"><a name="l00331"></a><span class="lineno">  331</span>&#160;      <a class="code" href="classpcl_1_1_static_range_coder.html#a72b5f38f745569b4ef06d1c6a4db9b74">Log2</a> (<span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span> (<a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[<span class="keyword">static_cast&lt;</span>std::size_t<span class="keyword">&gt;</span> (frequencyTableSize - 1)])) / 8.0));</div>
<div class="line"><a name="l00332"></a><span class="lineno">  332</span>&#160; </div>
<div class="line"><a name="l00333"></a><span class="lineno">  333</span>&#160;  <span class="comment">// write size of frequency table to output stream</span></div>
<div class="line"><a name="l00334"></a><span class="lineno">  334</span>&#160;  outputByteStream_arg.write (<span class="keyword">reinterpret_cast&lt;</span><span class="keyword">const </span><span class="keywordtype">char</span>*<span class="keyword">&gt;</span> (&amp;frequencyTableSize), <span class="keyword">sizeof</span>(frequencyTableSize));</div>
<div class="line"><a name="l00335"></a><span class="lineno">  335</span>&#160;  outputByteStream_arg.write (<span class="keyword">reinterpret_cast&lt;</span><span class="keyword">const </span><span class="keywordtype">char</span>*<span class="keyword">&gt;</span> (&amp;frequencyTableByteSize), <span class="keyword">sizeof</span>(frequencyTableByteSize));</div>
<div class="line"><a name="l00336"></a><span class="lineno">  336</span>&#160; </div>
<div class="line"><a name="l00337"></a><span class="lineno">  337</span>&#160;  streamByteCount += <span class="keyword">sizeof</span>(frequencyTableSize) + <span class="keyword">sizeof</span>(frequencyTableByteSize);</div>
<div class="line"><a name="l00338"></a><span class="lineno">  338</span>&#160; </div>
<div class="line"><a name="l00339"></a><span class="lineno">  339</span>&#160;  <span class="comment">// write cumulative  frequency table to output stream</span></div>
<div class="line"><a name="l00340"></a><span class="lineno">  340</span>&#160;  <span class="keywordflow">for</span> (f = 1; f &lt; frequencyTableSize; f++)</div>
<div class="line"><a name="l00341"></a><span class="lineno">  341</span>&#160;  {</div>
<div class="line"><a name="l00342"></a><span class="lineno">  342</span>&#160;    outputByteStream_arg.write (<span class="keyword">reinterpret_cast&lt;</span><span class="keyword">const </span><span class="keywordtype">char</span>*<span class="keyword">&gt;</span> (&amp;<a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[f]), frequencyTableByteSize);</div>
<div class="line"><a name="l00343"></a><span class="lineno">  343</span>&#160;    streamByteCount += frequencyTableByteSize;</div>
<div class="line"><a name="l00344"></a><span class="lineno">  344</span>&#160;  }</div>
<div class="line"><a name="l00345"></a><span class="lineno">  345</span>&#160; </div>
<div class="line"><a name="l00346"></a><span class="lineno">  346</span>&#160;  readPos = 0;</div>
<div class="line"><a name="l00347"></a><span class="lineno">  347</span>&#160;  low = 0;</div>
<div class="line"><a name="l00348"></a><span class="lineno">  348</span>&#160;  range = <span class="keyword">static_cast&lt;</span>uint64_t<span class="keyword">&gt;</span> (-1);</div>
<div class="line"><a name="l00349"></a><span class="lineno">  349</span>&#160; </div>
<div class="line"><a name="l00350"></a><span class="lineno">  350</span>&#160;  <span class="comment">// start encoding</span></div>
<div class="line"><a name="l00351"></a><span class="lineno">  351</span>&#160;  <span class="keywordflow">while</span> (readPos &lt; input_size)</div>
<div class="line"><a name="l00352"></a><span class="lineno">  352</span>&#160;  {</div>
<div class="line"><a name="l00353"></a><span class="lineno">  353</span>&#160; </div>
<div class="line"><a name="l00354"></a><span class="lineno">  354</span>&#160;    <span class="comment">// read symol</span></div>
<div class="line"><a name="l00355"></a><span class="lineno">  355</span>&#160;    inputsymbol = inputIntVector_arg[readPos++];</div>
<div class="line"><a name="l00356"></a><span class="lineno">  356</span>&#160; </div>
<div class="line"><a name="l00357"></a><span class="lineno">  357</span>&#160;    <span class="comment">// map to range</span></div>
<div class="line"><a name="l00358"></a><span class="lineno">  358</span>&#160;    low += <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[inputsymbol] * (range /= <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[<span class="keyword">static_cast&lt;</span>std::size_t<span class="keyword">&gt;</span> (frequencyTableSize - 1)]);</div>
<div class="line"><a name="l00359"></a><span class="lineno">  359</span>&#160;    range *= <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[inputsymbol + 1] - <a class="code" href="classpcl_1_1_static_range_coder.html#a8e3d92557b5e9b58164519a75b104cb5">cFreqTable_</a>[inputsymbol];</div>
<div class="line"><a name="l00360"></a><span class="lineno">  360</span>&#160; </div>
<div class="line"><a name="l00361"></a><span class="lineno">  361</span>&#160;    <span class="comment">// check range limits</span></div>
<div class="line"><a name="l00362"></a><span class="lineno">  362</span>&#160;    <span class="keywordflow">while</span> ((low ^ (low + range)) &lt; top || ((range &lt; bottom) &amp;&amp; ((range = -low &amp; (bottom - 1)), 1)))</div>
<div class="line"><a name="l00363"></a><span class="lineno">  363</span>&#160;    {</div>
<div class="line"><a name="l00364"></a><span class="lineno">  364</span>&#160;      out = <span class="keyword">static_cast&lt;</span><span class="keywordtype">char</span><span class="keyword">&gt;</span> (low &gt;&gt; 56);</div>
<div class="line"><a name="l00365"></a><span class="lineno">  365</span>&#160;      range &lt;&lt;= 8;</div>
<div class="line"><a name="l00366"></a><span class="lineno">  366</span>&#160;      low &lt;&lt;= 8;</div>
<div class="line"><a name="l00367"></a><span class="lineno">  367</span>&#160;      <a class="code" href="classpcl_1_1_static_range_coder.html#a47a655dfb4939a02e7b16af1ec649ae1">outputCharVector_</a>.push_back (out);</div>
<div class="line"><a name="l00368"></a><span class="lineno">  368</span>&#160;    }</div>
<div class="line"><a name="l00369"></a><span class="lineno">  369</span>&#160; </div>
<div class="line"><a name="l00370"></a><span class="lineno">  370</span>&#160;  }</div>
<div class="line"><a name="l00371"></a><span class="lineno">  371</span>&#160; </div>
<div class="line"><a name="l00372"></a><span class="lineno">  372</span>&#160;  <span class="comment">// flush remaining data</span></div>
<div class="line"><a name="l00373"></a><span class="lineno">  373</span>&#160;  <span class="keywordflow">for</span> (i = 0; i &lt; 8; i++)</div>
<div class="line"><a name="l00374"></a><span class="lineno">  374</span>&#160;  {</div>
<div class="line"><a name="l00375"></a><span class="lineno">  375</span>&#160;    out = <span class="keyword">static_cast&lt;</span><span class="keywordtype">char</span><span class="keyword">&gt;</span> (low &gt;&gt; 56);</div>
<div class="line"><a name="l00376"></a><span class="lineno">  376</span>&#160;    <a class="code" href="classpcl_1_1_static_range_coder.html#a47a655dfb4939a02e7b16af1ec649ae1">outputCharVector_</a>.push_back (out);</div>
<div class="line"><a name="l00377"></a><span class="lineno">  377</span>&#160;    low &lt;&lt;= 8;</div>
<div class="line"><a name="l00378"></a><span class="lineno">  378</span>&#160;  }</div>
<div class="line"><a name="l00379"></a><span class="lineno">  379</span>&#160; </div>
<div class="line"><a name="l00380"></a><span class="lineno">  380</span>&#160;  <span class="comment">// write encoded data to stream</span></div>
<div class="line"><a name="l00381"></a><span class="lineno">  381</span>&#160;  outputByteStream_arg.write (&amp;<a class="code" href="classpcl_1_1_static_range_coder.html#a47a655dfb4939a02e7b16af1ec649ae1">outputCharVector_</a>[0], <a class="code" href="classpcl_1_1_static_range_coder.html#a47a655dfb4939a02e7b16af1ec649ae1">outputCharVector_</a>.size ());</div>
<div class="line"><a name="l00382"></a><span class="lineno">  382</span>&#160; </div>
<div class="line"><a name="l00383"></a><span class="lineno">  383</span>&#160;  streamByteCount += <span class="keyword">static_cast&lt;</span><span class="keywordtype">unsigned</span> <span class="keywordtype">long</span><span class="keyword">&gt;</span> (<a class="code" href="classpcl_1_1_static_range_coder.html#a47a655dfb4939a02e7b16af1ec649ae1">outputCharVector_</a>.size ());</div>
<div class="line"><a name="l00384"></a><span class="lineno">  384</span>&#160; </div>
<div class="line"><a name="l00385"></a><span class="lineno">  385</span>&#160;  <span class="keywordflow">return</span> (streamByteCount);</div>
<div class="line"><a name="l00386"></a><span class="lineno">  386</span>&#160;}</div>
<div class="ttc" id="aclasspcl_1_1_static_range_coder_html_a72b5f38f745569b4ef06d1c6a4db9b74"><div class="ttname"><a href="classpcl_1_1_static_range_coder.html#a72b5f38f745569b4ef06d1c6a4db9b74">pcl::StaticRangeCoder::Log2</a></div><div class="ttdeci">double Log2(double n_arg)</div><div class="ttdoc">Helper function to calculate the binary logarithm</div><div class="ttdef"><b>Definition:</b> entropy_range_coder.h:173</div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a72b5f38f745569b4ef06d1c6a4db9b74"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a72b5f38f745569b4ef06d1c6a4db9b74">&#9670;&nbsp;</a></span>Log2()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">double pcl::StaticRangeCoder::Log2 </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>n_arg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Helper function to calculate the binary logarithm </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">n_arg</td><td>some value </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>binary logarithm (log2) of argument n_arg </dd></dl>
<div class="fragment"><div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;      {</div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;        <span class="keywordflow">return</span> log (n_arg) / log (2.0);</div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;      }</div>
</div><!-- fragment -->
</div>
</div>
<hr/>该类的文档由以下文件生成:<ul>
<li>io/include/pcl/compression/<a class="el" href="entropy__range__coder_8h_source.html">entropy_range_coder.h</a></li>
<li>io/include/pcl/compression/impl/<a class="el" href="entropy__range__coder_8hpp_source.html">entropy_range_coder.hpp</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><b>pcl</b></li><li class="navelem"><a class="el" href="classpcl_1_1_static_range_coder.html">StaticRangeCoder</a></li>
    <li class="footer">制作者 <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
